/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 * copy of the license can be found in the License.html file at the root of this distribution. If 
 * you cannot locate the  Microsoft Public License, please send an email to 
 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
 * PARTICULAR PURPOSE.
 * ***************************************************************************/


#include "stdafx.h"
#include <pgl/core/PGLBrush.h>
#include <pgl/core/PGLArchive.h>

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif


PGL_IMPLEMENT_DYNCREATE(CPGLBrush, CPGLNode);


//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

//! Save settings
void CPGLBrush::SerializeXML(CPGLArchive& ar)
{
	static TCHAR szTag[] = _T("CPGLBrush");

	CString str;
	markup::CMarkupArchive& xml = *((markup::CMarkupArchive*)ar.GetMarkup());
	if(ar.IsStoring())
	{
		xml.AddChildElem(szTag);
		xml.IntoElem();

			xml.AddChildElem(_T("BoundingBox"));
			xml.IntoElem();
				xml.AddChildElemEx(_T("Left"), m_rBBox.left);
				xml.AddChildElemEx(_T("Bottom"), m_rBBox.bottom);
				xml.AddChildElemEx(_T("Right"), m_rBBox.right);
				xml.AddChildElemEx(_T("Top"), m_rBBox.top);
			xml.OutOfElem();

		xml.OutOfElem();
	}
	else
	{
		if  (!xml.FindChildElem(szTag))
				return;


		xml.IntoElem();
			xml.ResetChildPos();
			if (xml.FindChildElem(_T("BoundingBox")))
			{
				xml.IntoElem();
					xml.FindGetChildData(_T("Left"),m_rBBox.left);
					xml.FindGetChildData(_T("Bottom"),m_rBBox.bottom);
					xml.FindGetChildData(_T("Right"),m_rBBox.right);
					xml.FindGetChildData(_T("Top"),m_rBBox.top);
				xml.OutOfElem();
			}
		xml.OutOfElem();
	}
}

#ifdef _DEBUG
void CPGLBrush::Dump( CDumpContext& dc ) const
{
    // call base class function first
    CObject::Dump( dc );

    // now do the stuff for our specific class
	dc << _T("CPGLBrush \n");
}
void CPGLBrush::AssertValid() const
{
    // call inherited AssertValid first
    CObject::AssertValid();

} 
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CPGLBrush::CPGLBrush(const CPGLRectD& rBBox)
{
	m_rBBox = rBBox;
}

CPGLBrush::~CPGLBrush()
{

}

CPGLBrush& CPGLBrush::operator = (const CPGLBrush& brush)
{
	if (this != &brush)
	{
		m_rBBox = brush.m_rBBox;
	}
	return *this;
}
